﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.MicroKernel.SubSystems.Configuration;
using DeStores.Common.DAL.Abstract;
using DeStores.Common.DAL.Manager;
using NHibernate;
using NHibernate.Cfg;
using System.Reflection;
using Castle.Core;

namespace DeStores.Constructor.UI.Web.MVC.Code.WindsorInstallers
{
    public class SessionFactoryInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            //container.Kernel.D += (ComponentModel client, DependencyModel model, object dependency) =>
            //    {
            //        string databaseName = "some_database";
            //    };
            //var sessionFactory = CreateSessionFactory();

            //container.Register(Component.For<IRepositoryManager>().ImplementedBy<RepositoryManager>()
            //    .DependsOn(new { sessionFactory  = sessionFactory})
            //    .LifeStyle.Singleton);
        }

        private ISessionFactory CreateSessionFactory()
        {
            var configuration = new Configuration();
            configuration.AddAssembly(Assembly.GetCallingAssembly());
            return configuration.BuildSessionFactory();
        }
    }
}